/*
 * Driver definitions for Hardware Pulse Width Detector Peripheral Module
 *
 * Authors: Rohit Kulkarni
 * 			Raviraj Kokil
 *
 * Date : 21st Feb, 2015
 */




/***************************** Include Files *******************************/
#include "HW_PWD_ip.h"

/***************************** Static variables *******************************/
static u32 HWPWD_BaseAddress;	// Base Address of the HWPWD register set

/************************** Function Definitions ***************************/
/**
* Initialize the HWPWD peripheral driver
*
* Saves the Base address of the HW_PWD registers for further accesses to the Hardware Pulse Width Detector Module Registers.
*
* @param	BaseAddr is the base address of the HW_PWD register set
*
* @return
* 		- XST_SUCCESS	Initialization was successful.
*
* @note		The Base Address of the PmodECE544IO peripheral will be in xparameters.h
*****************************************************************************/
XStatus HWPWD_initialize(u32 BaseAddr)
{
	XStatus sts;
	u32 rslt;


	// Save the Base Address so we know where to point the driver
	// Uses the static variable BaseAddr to store it.
	HWPWD_BaseAddress = BaseAddr;

	sts	= XST_SUCCESS;						//return success on initialization

	return sts;
}


/****************************************************************************/
/**
* Read low count from the HWPWDT
*
* @param :  No input arguments	 
*
* @return:  Count is returned as a 32 bit unsigned value*
*****************************************************************************/

u32 Read_Low_Count()
{
	u32 low_count;

	low_count =  HW_PWD_IP_mReadReg(HWPWD_BaseAddress, HW_PWD_IP_S00_AXI_SLV_REG0_OFFSET);

	return low_count;
}

/****************************************************************************/
/**
* Read high count from the HWPWDT
*
* @param :  No input arguments	 
*
* @return:  Count is returned as a 32 bit unsigned value*
*****************************************************************************/

u32 Read_High_Count()
{
	u32 high_count;

	high_count =  HW_PWD_IP_mReadReg(HWPWD_BaseAddress, HW_PWD_IP_S00_AXI_SLV_REG1_OFFSET);

	return high_count;
}

